package com.smartwork.modules.sys.server;

/**
 * Created by guomiaoyi on 2015/12/3.
 */

import com.smartwork.common.mobile.constant.ResponseCodeConst;
import com.smartwork.common.mobile.vo.BaseRequestData;
import com.smartwork.common.mobile.vo.BaseResponseData;
import com.smartwork.common.mobile.web.BaseController;
import com.smartwork.modules.sys.entity.ClientVersion;
import com.smartwork.modules.sys.service.ClientVersionService;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * author ym 2015/12/03
 * 功能：查询版本信息
 */
@Controller
@RequestMapping(value = {"${mobliePath}/sys"})
@Scope("prototype")
public class ClientVersionServer extends BaseController {


    @Autowired
    private ClientVersionService clientVersionService;

    /**
     * 查询版本信息
     *
     * @param requestData
     * @return
     */
    @RequestMapping(value = {"ver/maxVersion"})
    @ResponseBody
    public BaseResponseData getMaxVersion(BaseRequestData requestData) {
        ClientVersion clientVersion = new ClientVersion();
        try {
            BeanUtils.copyProperties(clientVersion, requestData);
        } catch (Exception e) {
            logger.error("copy Properties error", e);
        }
        Map<String, Object> retMap = clientVersionService.getMaxVersion(clientVersion);
        return sendResponseData(ResponseCodeConst.SUCCESS, "查询版本信息成功", null, retMap);
    }

}
